<?php
apf_require_class("APF_Component");

class Qa_SelectDePartMentComponent extends APF_Component {
    public function get_view() {
        $result = APF::get_instance()->get_request()->get_attribute('selectdata');
        if(empty($result)){
            $bll = new Bll_Hr_Property();
            $result['company'] = $bll->get_company_list();
            $result['citylist'] = $bll->get_sort_city_list();
            $result['business'] = $bll->get_business_list();
            $result['function'] = $bll->get_function_list();
        }
        $params = APF::get_instance()->get_request()->get_attribute('params');
        if(!empty($params)){
            $result = array_merge($result,$params);
        }
        $no_company = $this->get_params();
        //根据角色限制权限
        $allow = APF::get_instance()->get_config('qa_auth','auth');
        if(!in_array($_SESSION['user_code'],$allow)){
            $city = empty($_SESSION['role_list'][Const_Flow::ROLE_HR]) ? array() : $_SESSION['role_list'][Const_Flow::ROLE_HR];
            foreach($result['citylist'] as $city_id=>$val){
                if(!in_array($city_id,$city)){
                    unset($result['citylist'][$city_id]);
                    continue;
                }
            }
        }
        if(empty($no_company)){
            $no_company=0;
        }
        $this->assign_data('no_company', $no_company);
        $this->assign_data('selectdata', $result);
        return 'SelectDePartMent';
    }
}